Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Tasks: add discover-ec2 task type #47062

Merged
merged 3 commits into from
Oct 4, 2024

Conversation

marcoandredinis
Copy link
Contributor

@marcoandredinis marcoandredinis commented Oct 1, 2024

This PR adds more business logic into discover-ec2 User Task.

One of the key features of the DiscoverEC2 User Tasks is that we must have a single task per:

  • integration
  • region
  • account id
  • issue type

This allows user to have a detailed view of the issues their are facing but still grouping EC2 instances.

To do this, we had to move the region and account id up one level. Previously they were at the instance level, and it would require iterating over them to actually create the group (uniq key) we want.

This also adds well known errors as issue types so that we can do validations on the tasks.

A later PR will come where we actually start creating/updating DiscoverEC2 User Tasks from the DiscoveryService.

Context: #41909

@marcoandredinis marcoandredinis added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v16 labels Oct 1, 2024
@marcoandredinis marcoandredinis marked this pull request as ready for review October 1, 2024 20:59
@marcoandredinis marcoandredinis force-pushed the marco/discover_ec2_tasks branch from 4e32211 to 873c321 Compare October 2, 2024 08:08
lib/services/local/user_task_test.go Outdated Show resolved Hide resolved
@marcoandredinis marcoandredinis force-pushed the marco/discover_ec2_tasks branch 2 times, most recently from 5e20588 to 497f0aa Compare October 3, 2024 16:37
@tigrato tigrato self-requested a review October 3, 2024 17:42
api/proto/teleport/usertasks/v1/user_tasks.proto Outdated Show resolved Hide resolved
api/proto/teleport/usertasks/v1/user_tasks.proto Outdated Show resolved Hide resolved
api/types/autodiscover.go Outdated Show resolved Hide resolved
api/types/autodiscover.go Outdated Show resolved Hide resolved
api/types/autodiscover.go Outdated Show resolved Hide resolved
const (
// TaskTypeDiscoverEC2 identifies a User Tasks that is created
// when an auto-enrollment of an EC2 instance fails.
// UserTasks that have this Task Type must include the DiscoverEC2 field.
TaskTypeDiscoverEC2 = "discover-ec2"
)

// discoverEC2IssueTypes is a list of issue types that can occur when trying to auto enroll EC2 instances.
var discoverEC2IssueTypes = []string{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we move this closer to the types definition so it's easier to keep them aligned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change it 👍
The reasoning here is that I was trying to not add usertasks specific things to types.
I was also trying to add generic EC2 Auto Discover failures so that we can use them everywhere, even if not related to usertasks.

Well, thinking about this now, I think it's fine to not pursue one of the above goals.

I'll move the identifiers from types into usertasks.

This PR adds more business logic into the User Tasks, in particular into
the `discover-ec2` task type.

One of the key features of the DiscoverEC2 User Tasks is that we must
have a single task per:
- integration
- region
- account id
- issue type

This allows user to have a detailed view of the issues their are facing
but still grouping EC2 instances.

To do this, we had to move the region and account id up one level.
Previously they were at the instance level, and it would require
iterating over them to actually create the group (uniq key) we want.

This also adds well known errors as issue types to ensure we validate
them.

A later PR will come where we actually start creating/updating
DiscoverEC2 User Tasks from the DiscoveryService.
@marcoandredinis marcoandredinis force-pushed the marco/discover_ec2_tasks branch from 497f0aa to 649c8be Compare October 4, 2024 10:11
@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from camscale October 4, 2024 10:25
@marcoandredinis marcoandredinis force-pushed the marco/discover_ec2_tasks branch from 649c8be to 43cbfc1 Compare October 4, 2024 10:31
@marcoandredinis marcoandredinis added this pull request to the merge queue Oct 4, 2024
Merged via the queue into master with commit 4d1f1b9 Oct 4, 2024
42 checks passed
@marcoandredinis marcoandredinis deleted the marco/discover_ec2_tasks branch October 4, 2024 11:22
@public-teleport-github-review-bot

@marcoandredinis See the table below for backport results.

Branch Result
branch/v16 Failed

marcoandredinis added a commit that referenced this pull request Oct 4, 2024
* User Tasks: add `discover-ec2` task type

This PR adds more business logic into the User Tasks, in particular into
the `discover-ec2` task type.

One of the key features of the DiscoverEC2 User Tasks is that we must
have a single task per:
- integration
- region
- account id
- issue type

This allows user to have a detailed view of the issues their are facing
but still grouping EC2 instances.

To do this, we had to move the region and account id up one level.
Previously they were at the instance level, and it would require
iterating over them to actually create the group (uniq key) we want.

This also adds well known errors as issue types to ensure we validate
them.

A later PR will come where we actually start creating/updating
DiscoverEC2 User Tasks from the DiscoveryService.

* use strings.Compare

* improve docs and fix typos
github-merge-queue bot pushed a commit that referenced this pull request Oct 4, 2024
* User Tasks: add `discover-ec2` task type

This PR adds more business logic into the User Tasks, in particular into
the `discover-ec2` task type.

One of the key features of the DiscoverEC2 User Tasks is that we must
have a single task per:
- integration
- region
- account id
- issue type

This allows user to have a detailed view of the issues their are facing
but still grouping EC2 instances.

To do this, we had to move the region and account id up one level.
Previously they were at the instance level, and it would require
iterating over them to actually create the group (uniq key) we want.

This also adds well known errors as issue types to ensure we validate
them.

A later PR will come where we actually start creating/updating
DiscoverEC2 User Tasks from the DiscoveryService.

* use strings.Compare

* improve docs and fix typos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v16 no-changelog Indicates that a PR does not require a changelog entry size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants